/**
 * 成员管理页
 */

(function(){
	com.hp.demo.vteam.components.AccountManager = Ext.extend(com.hp.demo.vteam.base.GridPanel,{
		flex:1,
		fullscreen:true,
		colModel:[
	        {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_MANAGER_NAME,mapping:'name'},
	        {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_MANAGER_GENDER,mapping:'gender'},
	        {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_MANAGER_WORKEMAIL,mapping:'workEmail'},
	        {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_MANAGER_TEL,mapping:'tel'},
	        {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_MANAGER_MOBILE,mapping:'mobile'},
	        {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_GROUP_NAME,mapping:'accountGroup.id'},
		    {header:com.hp.demo.vteam.dict.FIELDS.ACCOUNT_MANAGER_AUTHOR,mapping:'addedBy.email'},
		    {header:com.hp.demo.vteam.dict.FIELDS.DESC,mapping:'desc'},
		    {header:com.hp.demo.vteam.dict.FIELDS.ADDED_TIME,mapping:'addedTime'}
	    ],
		initComponent:function()
		{
		    Ext.apply(this,{
				store:com.hp.demo.vteam.base.QueryPageStore({
					url:com.hp.demo.vteam.dict.REQUEST.AccountManager,
					model:'AccountManager',
					errorMsg:com.hp.demo.vteam.dict.ERRORS.QUERY_ACCOUNT_MANAGER_SYS
				}),
				pagenation:[
					{id:'create'},
					{id:'modify'},
					{id:'remove'}
				],
		        create:function()
			    {
				    com.hp.demo.vteam.base.Action('CreateAccountManager',com.hp.demo.vteam.dict.FUNC_TITLE.CreateAccountManager);
			    },
			    modify:function()
				{
					var items = this.dataview;
					if(items.getSelectionCount() == 0)
					{
						com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.ERRORS.CHOOSEN_LEAST_ONE);
					}
					else
					{
						var record = items.getSelectedRecords()[0];
						com.hp.demo.vteam.base.Action('ModifyAccountManager',
							com.hp.demo.vteam.dict.FUNC_TITLE.ModifyAccountManager,
							{'accountManager':record}
						);
					}
				},
				remove:function()
				{
					var context = this,
					    items = context.dataview;
					if(items.getSelectionCount() == 0)
					{
						com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.ERRORS.CHOOSEN_LEAST_ONE);
					}
					else
					{
						var record = items.getSelectedRecords()[0];
						Ext.Ajax.request({
							url:com.hp.demo.vteam.dict.REQUEST.AccountManager,
							params:{
								method:'del',
								id:record.get('id')
							},
							success:function(){
								com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.SUCCESSES.DELETE_ACCOUNT_MANAGER);
								setTimeout(function(){
									context.loadData();
								},1000);
							},
							failure:function(){
								com.hp.demo.vteam.base.status_msg(com.hp.demo.vteam.dict.ERRORS.DELETE_ACCOUNT_MANAGER_SYS);
							}
						});
					}
				}
			});
			com.hp.demo.vteam.components.AccountManager.superclass.initComponent.call(this);
		}
	});
	return com.hp.demo.vteam.components.AccountManager;
})();



